﻿@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: true *@
@using LogDashboard.Extensions
@using LogDashboard.StackTrace
@using LogDashboard.Models
@inherits LogDashboard.Views.RazorPage
@{
  
    var log = (ILogModel)ViewData["Model"];

}
<div class="container-fluid">
    <div class="mb-4 open">
        <ul class="nav nav-tabs" role="tablist">
            <li class="nav-item">
                <a class="nav-link active" data-toggle="tab" href="#overview" role="tab" aria-controls="overview" aria-selected="true">概览</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" data-toggle="tab" href="#environment" role="tab" aria-controls="environment" aria-selected="false">其他</a>
            </li>
            @{
                if (typeof(IRequestTraceLogModel).IsAssignableFrom(Context.Options.LogModelType))
                {
                    <li class="nav-item">

                        <a class="nav-link" data-toggle="tab" href="#requestTrace" role="tab" aria-controls="requestTrace" onclick="requestTrace('@log.Id.ToString()')" aria-selected="false">请求追踪</a>
                    </li>
                }

            }
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="overview" role="tabpanel">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <tbody>
                            <tr>
                                <td>Id</td>
                                <td class="text-nowrap">@log.Id.ToString()</td>
                            </tr>
                            <tr>
                                <td>时间</td>
                                <td class="text-nowrap">@log.LongDate.ToString("yyyy-MM-dd HH:mm:ss")</td>
                            </tr>
                            <tr>
                                <td>级别</td>
                                <td class="text-nowrap"><button class="btn btn-outline-@log.Level.ToUpper()">@log.Level.ToUpper()</button></td>
                            </tr>
                            <tr>
                                <td>Logger</td>
                                <td class="text-nowrap">@log.Logger</td>
                            </tr>
                            <tr>
                                <td>消息</td>
                                <td class="text-nowrap">@log.Message</td>
                            </tr>

                        </tbody>
                    </table>
                    <div class="card">
                        <div class="card-header bg-light">
                            堆栈信息
                        </div>
                        <div class="card-body">
                            <pre>@Raw(StackTraceFormatter.FormatHtml(log.Exception))</pre>
                        </div>
                    </div>
                </div>
            </div>

            <div class="tab-pane" id="environment" role="tabpanel">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <tbody>
                            @{
                                foreach (var propertyInfo in Context.Options.CustomPropertyInfos)
                                {
                                    <tr>
                                        <td style="width: 13%">@propertyInfo.Name</td>
                                        <td class="text-nowrap">@propertyInfo.GetValue(log)</td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="tab-pane" id="requestTrace" role="tabpanel">
                <div class="table-responsive">
                    <div id="traceLogList">

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>